<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
</body>
</html>
<script>
  function fn(data) {
        var newData = null;    //仓库引用 
        function type(data){   //判断指针 
            return Object.prototype.toString.call(data)
        }
        if(type(data) == "[object String]"){
            // alert("参数是String")
            newData = "";       //提升定义仓库 
            // for(let i=0; i<data.length; i++){      //str去重1  
            //     if(!newData.includes(data[i])){  
            //         newData+=data[i]
            //     }
            // }
            //      for(let i=0; i<data.length; i++){  //str去重2 
            //      if(newData.indexOf(data[i]) === -1){
            //         newData+=data[i]
            //     }
            // }
            return newData
        }
        if(type(data) == "[object Array]"){
            // alert("参数是Array")
            newData = [];       //提升定义仓库
            // newData = [...new Set(data)]          //arr去重1 
            // newData = Array.from(new Set(data))   //arr去重2 
            // newData = data.filter((x, index,self)=>self.indexOf(x)===index)   //方法3去重
        }                                            // indexOf 返回某个指定的字符串值在字符串中首次出现的位置。
        return newData                               // 对大小写敏感 
    }                                                // 如果要检索的字符串值没有出现过，则该方法返回 -1。
    // var data = "aasdasdasasdas";  str测 
    var data = [1,2,1,2,1,2] 
    console.log(fn(data))  //  asd    // 1 2 

    var b = [
    {month: '1月', patientRegisteredNumber: 0, signUpTotalNumber: 0},
    {month: '2月', patientRegisteredNumber: 0, signUpTotalNumber: 0},
    {month: '3月', patientRegisteredNumber: 0, signUpTotalNumber: 0},
    {month: '4月', patientRegisteredNumber: 0, signUpTotalNumber: 0},
    {month: '5月', patientRegisteredNumber: 0, signUpTotalNumber: 0},
    {month: '6月', patientRegisteredNumber: 0, signUpTotalNumber: 0},
    {month: '7月', patientRegisteredNumber: 0, signUpTotalNumber: 0},
    {month: '8月', patientRegisteredNumber: 18, signUpTotalNumber: 0},
    {month: '9月', patientRegisteredNumber: 37, signUpTotalNumber: 7},
    {month: '10月', patientRegisteredNumber: 8, signUpTotalNumber: 46},
    {month: '11月', patientRegisteredNumber: 2, signUpTotalNumber: 15},
    {month: '12月', patientRegisteredNumber: 0, signUpTotalNumber: 0},
  ]
  // 数组 对象转数组 
  // let _arr = b.map((i)=>{
  //    let arr = [];
  //    arr.push(i.month);
  //    arr.push(i.patientRegisteredNumber); 
  //    arr.push(i.signUpTotalNumber); 
  //   return arr
  // })
  // console.log(_arr);

 // 属性名替换  
  function handleKey(b){
    console.log(b);
    b.forEach(elem => {
      elem['name'] = elem.month;                           
      elem[''] = elem.patientRegisteredNumber;
      elem['c'] = elem.signUpTotalNumber;
        delete elem.month;   // 删去被替换节点   
        delete elem.patientRegisteredNumber;
        delete elem.signUpTotalNumber
	  })
	return b
  }
  handleKey(b)  
  /*
    0: {a: '1月', b: 0, c: 0}
    1: {a: '2月', b: 0, c: 0}  .....
  */


</script>